home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6595 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  54 lines

  1. Newsgroups: comp.lang.c
  2. Path: lafn.org!an234
  3. From: an234@lafn.org (Andres Lessing)
  4. Subject: Re: Can someone help me with fopen
  5. X-Nntp-Posting-Host: lafn.org
  6. Message-ID: <1996Feb14.070619.20564@lafn.org>
  7. Sender: news@lafn.org
  8. Reply-To: an234@lafn.org (Andres Lessing)
  9. Organization: The Los Angeles Free-Net
  10. References: <4fouoo$k0e@news.uncc.edu>  
  11. Date: Wed, 14 Feb 1996 07:06:19 GMT
  12.  
  13.  
  14. In a previous article, ssfeebac (Samuel S Feeback) says:
  15.  
  16. >Here is my problem.  I am trying to read a text file, search for a certain
  17. >string and write that string to an outfile.  I am having trouble with the fopen
  18. >commnad. Here is a fragment of my code.
  19. >
  20. >char input; /* variable to put filename in*/
  21. >FILE *infile /* Pointer to File to be used as input */
  22. >
  23. >if (argv[argc] == "-i")
  24. >    {input = ((argv[argc]) + 1);
  25. >     infile = fopen((("%s", input), "r"));
  26. >     if ((infile = fopen((("%s", input), "r"))) == NULL)
  27. >        {/*Error Message*/
  28. >
  29. >
  30. >I keep getting an "too few arguments to function `fopen'
  31. >
  32. >Please e-mail me is you have any idea on this problem(or any other aspect of
  33. >    this program for that matter :>)
  34. >Any help would be greatly appreciated
  35. >
  36. >ssfeebac@uncc.edu
  37. >
  38. >
  39.  
  40. If I am not mistaken, I believe that fopen has the following parameters:
  41. fopen(filename,fileopenmode);
  42.  
  43. for example here's how you would do it
  44.  
  45. infile = fopen(input,"r");
  46. then you do your stuff.
  47.  
  48. E-mail me if you have any questions...
  49. -- 
  50.  Hofstadter's Law:                   |       o__
  51.     It always takes longer than you expect, even   |     _.</)_
  52.     when you take Hofstadter's Law into account.   |    (_) \(_)
  53.         " Godel Escher Bach"               | Andres, an234@lafn.org
  54.